<%@ page language="java" isELIgnored="false"%>
<%@include file="../common/taglib.jsp"%>

<div id="Conteudo">
	<html:form action="regra">
		<html:hidden property="codigo"></html:hidden>
		<html:hidden property="method"></html:hidden>
		<html:hidden property="state"></html:hidden>
		<h1><bean:message key="regra.label.descricao"/>:<span><bean:message key="subtitulo.label.cadastro"/></span> </h1>
		<div class="campo">
			<label>
				<bean:message key="regra.label.descricao"/><span>*</span>
			</label> 
			<html:text property="descricao" style="width:500px;" maxlength="100"></html:text>
		</div>		
		<div class="campo">
			<label>
				<bean:message key="regra.label.ordem"/><span>*</span>
			</label> 	
			<html:text property="ordem" style="width:50px;" maxlength="4"></html:text>
		</div>				
		<br clear="all"/>
		<div class="campo">
			<label>
				<bean:message key="regra.label.se"/><span>*</span>
			</label>
			<html:select property="variavel.codigo">
				<option value=""><bean:message key="select.option.label.selectone"/></option>
				<trex:options 
						source="br.com.ia.business.VariavelBusiness.retrieveAll()" 
						property="codigo" labelProperty="descricao" />
			</html:select>
		</div>
		<div class="campo">
			<label>
				&nbsp;
			</label>
			<html:select property="operador">
				<html:option value=""><bean:message key="select.option.label.selectone"/></html:option>
				<trex:options source="br.com.ia.business.OperadorBusiness.retrieveAll()" property="codigo" labelProperty="sigla"/>
			</html:select>
		</div>
		<div class="campo">
			<label>
				<bean:message key="valor.label.descricao"/><span>*</span>
			</label>
			<trex:dependentSelect property="valor.codigo" depends="variavel.codigo" name="RegraForm">
				<trex:dependentOptions 
						source="br.com.ia.business.VariavelBusiness.bucarValorPorVariavel(java.lang.Integer:variavel.codigo)" 
						property="codigo" 
						labelProperty="descricao"/>
			</trex:dependentSelect>
		</div>	
		
		<br clear="all"/>
		<div class="campo">
				<label>
					<bean:message key="regra.label.entao"/><span>*</span>
				</label> 			
				<html:select property="cdVariavelConclusao">
					<option value=""><bean:message key="select.option.label.selectone" /></option>
					<trex:options
						source="br.com.ia.business.VariavelBusiness.retrieveAll()"
						property="codigo" labelProperty="descricao" />
				</html:select>
		</div>
		<div class="campo">
			<label> &nbsp; </label>
			<input type="text" value="=" style="background: none; width: 69px; border: none;" size="20px;"/>
		</div>
		<div class="campo">			
				<label>
					<bean:message key="valor.label.descricao"/><span>*</span>
				</label> 
				<trex:dependentSelect property="cdValorConclusao" depends="cdVariavelConclusao" name="RegraForm">
					<trex:dependentOptions 
						source="br.com.ia.business.VariavelBusiness.bucarValorPorVariavel(java.lang.Integer:cdVariavelConclusao)" 
						labelProperty="descricao" 
						property="codigo"/>
				</trex:dependentSelect>
		</div>
	</html:form>
	
	<%-- <facility-tags:error/>	--%>
	
</div>
<script>
	
	function cancelar(){
		
		document.RegraForm.method.value = 'prepareSearch';
		document.RegraForm.submit();		
	}
	
	function salvar(){
		
		var estado = document.RegraForm.state.value;
		
		if (estado == 'insert'){
			document.RegraForm.method.value = 'insert';
		}
		else if (estado == 'update'){
			document.RegraForm.method.value = 'update';
		}
				
		document.RegraForm.submit();		
	}
	
</script>